package com.chagee.store.operation.common.utils;

import com.chagee.base.utils.PaginationData;
import com.chagee.base.utils.PaginationRequest;

import java.util.Collections;
import java.util.List;

/**
 * @author: chang.jiawei
 * @date: 2024/01/23
 */
public class ResponseUtil {

	public static <T> PaginationData<T> emptyResponse(PaginationRequest<?> request,
													  Class<T> clazz,
													  Long total) {
		PaginationData<T> result = new PaginationData<>();
		result.setPageNum(request.getPageNum());
		result.setPageSize(request.getPageSize());
		result.setTotal(total);
		result.setPageList(Collections.emptyList());
		return result;
	}

	public static <T> PaginationData<T> commonResponse(PaginationRequest<?> request,
													   List<T> lists,
													   Long total) {
		PaginationData<T> result = new PaginationData<>();
		result.setPageNum(request.getPageNum());
		result.setPageSize(request.getPageSize());
		result.setTotal(total);
		result.setPageList(lists);
		return result;
	}
}
